<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>添加考试</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="__PUBLIC__/BeginnerAdmin/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="__PUBLIC__/BeginnerAdmin/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="__PUBLIC__/Jquery/Pulgin/lou-multi-select-e052211/css/multi-select.css">

    <style>
        .search-input {
            box-sizing: border-box;
            -moz-box-sizing: border-box;
            width: 100%;
            margin-bottom: 5px;
            height: auto;
            padding: 4px 6px;

            border-radius: 4px;
            background-color: #fff;
            border: 1px solid #ccc;
        }
    </style>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>添加考试</legend>
</fieldset>
<form class="layui-form layui-form-pane" action="#" style="width: 90%">

    <input type="hidden" id="examassignmentid" name="examassignmentid" lay-verify="examassignmentid" value="<{$examassignmentid}>">
        <div class="layui-form-item">
            <label class="layui-form-label">年级分组</label>
            <div class="layui-input-block">
                <select name="gradegroup" id="gradegroup" lay-filter="gradegroup" lay-verify="gradegroup" lay-search>
                    <foreach name="grade" item="vo" >
                        <option <if condition="$vo.id eq $gradegroup">selected</if> value="<{$vo.id}>"><{$vo.name}></option>
                    </foreach>

                </select>
            </div>
        </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">添加学生</label>
        <br>
        <div align="center" class="layui-input-block">
            <select multiple="multiple" id="studentadd" class="studentadd" lay-ignore lay-verify="studentadd" name="studentadd">
                <foreach name="student_information" item="vo" >
                    <option align="left" <if condition="$vo.studentexamid neq null && $vo.assignmentid eq $examassignmentid ">selected</if>  value='<{$vo.uid}>'><{$vo.name}></option>
                </foreach>
            </select>
        </div>
    </div>

        <div class="layui-form-item">
            <div class="layui-input-block">

                <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>

</form>

<!--
<script type="text/javascript" src="__PUBLIC__/BeginnerAdmin/plugins/laydate/laydate.js"></script>-->
<script type="text/javascript" src="__PUBLIC__/BeginnerAdmin/plugins/layui/layui.js"></script>
<script type="text/javascript" src="__PUBLIC__/AmazeUI/assets/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/Jquery/Pulgin/lou-multi-select-e052211/js/jquery.multi-select.js"></script>
<script type="text/javascript" src="__PUBLIC__/Jquery/Pulgin/quicksearch/jquery.quicksearch.js"></script>
<script>
    $('#studentadd').multiSelect({
        selectableHeader: "<input type='text' class='search-input ' autocomplete='off' placeholder='搜索的名字'>",
        selectionHeader: "<input type='text' class='search-input ' autocomplete='off' placeholder='搜索的名字'>",
        afterInit: function(ms){
            var that = this,
                $selectableSearch = that.$selectableUl.prev(),
                $selectionSearch = that.$selectionUl.prev(),
                selectableSearchString = '#'+that.$container.attr('id')+' .ms-elem-selectable:not(.ms-selected)',
                selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';

            that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
                .on('keydown', function(e){
                    if (e.which === 40){
                        that.$selectableUl.focus();
                        return false;
                    }
                });

            that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
                .on('keydown', function(e){
                    if (e.which == 40){
                        that.$selectionUl.focus();
                        return false;
                    }
                });
        },
        afterSelect: function(){
            this.qs1.cache();
            this.qs2.cache();
        },
        afterDeselect: function(){
            this.qs1.cache();
            this.qs2.cache();
        }
    });
    function settime() {
        var index=parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }

    layui.use(['form','laydate'], function() {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate
        ;
        //自定义验证规则
        form.verify({
            gradegroup: function(value) {
                if(value.length  == '' ) {
                    return '年级分组必须选择';
                }
            }

        });

        form.on('select(gradegroup)', function(data){
            window.location.href = '<{:U("Paper/NewPaperStudentUI",array('examassignmentid'=>$examassignmentid))}>?gradegroup='+data.value;
        });
        //监听提交
        form.on('submit(demo1)', function(data) {
            data.field.studentadd = $("#studentadd").val()
            $.post('Admin_Paper_NewPaperStudent.html',data.field,function (ret) {
                if(ret.code == 200){
                    layer.msg('考试信息修改成功');
                    setTimeout('settime()', 1500);//延时执行，让人看得更清楚
                }else{
                    layer.alert(ret.msg);
                }
            },'json');
            return false;
        });
    });
</script>
</body>
</html>